<template>
  <div>
    <search-form
      :search-config="searchConfig"
      :label-width="150"
      @clear="clearSearch"
      @search="handleSearch"
    />
    <c-permission-tabs v-model="activeType" code="tab">
      <el-tab-pane label="全部" name="all" opt-code="all">
        <List :active-type="activeType" :serach-filters="serachFilters" type="all" />
      </el-tab-pane>
      <el-tab-pane label="待审核" name="waitAudit" opt-code="audit">
        <List :active-type="activeType" :serach-filters="serachFilters" type="waitAudit" />
      </el-tab-pane>
    </c-permission-tabs>
  </div>
</template>
<script>
import List from './components/List'
export default {
  name: 'ShopDrawingAudit',
  components: {
    List
  },
  data() {
    return {
      activeType: '',
      searchConfig: [
        // {
        //   label: '图纸批次号',
        //   prop: 'picBatchCode',
        //   type: 'text',
        //   value: ''
        // },
        {
          type: 'select',
          prop: 'picType',
          label: '图纸类型',
          value: '',
          placeholder: '图纸类型',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/PIC_TYPE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'designRange',
          label: '设计范围',
          value: '',
          placeholder: '设计范围',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/DECORATION_RANGE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          label: '门店建设项目号',
          prop: 'constCode',
          type: 'text',
          value: '',
          placeholder: '门店建设项目号'
        },
        {
          label: '图纸任务号',
          prop: 'picTaskCode',
          type: 'text',
          value: '',
          placeholder: '图纸任务号'
        },
        {
          label: '图纸任务名称',
          prop: 'picTaskName',
          type: 'text',
          value: '',
          placeholder: '图纸任务名称'
        },
        {
          label: '所属门店',
          prop: 'shopCode',
          type: 'dialog',
          value: '',
          placeholder: '所属门店',
          config: {
            requestMethod: 'post',
            paramField: 'paramKeyword', // 远程搜索参数名
            defaultProps: {
              label: 'name',
              value: 'code'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '所属门店',
            interfacePath:
              '/select-service/api/v1/shop/page',
            setting: [
              { prop: 'code', title: '编码' },
              { prop: 'name', title: '名称' }
            ]
          }
        },
        {
          type: 'dialog',
          prop: 'designSpace',
          label: '设计区域',
          value: '',
          placeholder: '设计区域',
          operator: 'like',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/slm-admin/api/v1/configArea/page`,
            requestMethod: 'post',
            defaultProps: {
              label: 'areaName',
              value: 'areaCode'
            }
          },
          dialogConfig: {
            title: '设计区域',
            interfacePath:
              '/slm-admin/api/v1/configArea/page',
            filtersRaw: [{ id: 'enable', property: 'enable', operator: '=', value: '1' }],
            setting: [
              { prop: 'areaCode', title: '编码' },
              { prop: 'areaName', title: '名称' }
            ]
          }
        },
        {
          label: '设计单位',
          prop: 'designUnitCode',
          type: 'dialog',
          value: '',
          placeholder: '设计单位',
          config: {
            requestMethod: 'get',
            // paramField: 'paramKeyword', // 远程搜索参数名
            defaultProps: {
              label: 'orgName',
              value: 'orgCode'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '设计单位',
            method: 'get',
            interfacePath:
              '/slm-admin/api/v1/user/orgTreeByType?type=9',
            setting: [
              { prop: 'orgCode', title: '编码' },
              { prop: 'orgName', title: '名称' }
            ]
          }
        },
        {
          type: 'select',
          prop: 'picUrgentLevel',
          label: '紧急程度',
          value: '',
          placeholder: '紧急程度',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/PIC_URGENT_LEVEL`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'isFocusMarket',
          label: '是否重点卖场',
          value: '',
          placeholder: '是否重点卖场',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/BOOLEANS`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'isKaMarket',
          label: '是否KA卖场',
          value: '',
          placeholder: '是否KA卖场',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/BOOLEANS`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'shopLevelCode',
          label: '店面等级',
          value: '',
          placeholder: '店面等级',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/SHOP_LEVEL_CODE`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          type: 'select',
          prop: 'isRedesign',
          label: '是否重复设计',
          value: '',
          placeholder: '是否重复设计',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/BOOLEANS`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        },
        {
          label: '审批人',
          prop: 'approverCode',
          type: 'dialog',
          value: '',
          placeholder: '审批人',
          config: {
            requestMethod: 'post',
            remoteUrl: '/slm-admin/api/v1/user/domainUser/page',
            // paramField: 'paramKeyword', // 远程搜索参数名
            defaultProps: {
              label: 'userName',
              value: 'account'
            }, // api返回数据默认字段
            selectData: []
          },
          dialogConfig: {
            title: '审批人',
            method: 'post',
            interfacePath:
              '/slm-admin/api/v1/user/domainUser/page',
            setting: [
              { prop: 'account', title: '编码' },
              { prop: 'userName', title: '名称' }
            ]
          }
        },
        {
          type: 'select',
          prop: 'isApproval',
          label: '审批进度',
          value: '',
          placeholder: '审批进度',
          config: {
            remote: true,
            // paramField: 'keyWord', // 远程搜索参数名
            remoteUrl: `/data-dict/api/v2/dictionary/APPROVAL_STEPS`,
            defaultProps: {
              label: 'dictName',
              value: 'dictCode'
            },
            paramsRaw: { appCode: 'slm', domainCode: 'marketing' }
          }
        }
      ],
      serachFilters: []
    }
  },
  methods: {
    clearSearch(data) {
      this.serachFilters = []
    },
    // 获取搜索条件
    handleSearch(data) {
      this.serachFilters = data.filtersRaw
    }
  }
}
</script>
